<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="/fuman/js/oversea.js"></script>
<script language="javascript" src="/fuman/js/TableFreeze.js"></script>
<title>库存需求列表｜海外仓管理</title>
<script type="text/javascript">
	jQuery(document).ready(function(){
		
	});
	function submitRquestGoods(t){
		if(confirm("确定执行吗?")){
			$("#submittype").val(t);
			$("#mainform").submit();
		}
	}
	function savepackingPro()
	{
		var str = selectallpro();
		if (str != false)
		{
			$.post("/oversea/ajaxbutton", {"op": "savepackingPro","uid":str},
			 function(data){
				 var is = 1;
				 if(data.shop>1)
				 {
					 is = 0;
					 alert("一次只能生成一个店铺的运输计划，所选列表包含"+data.shop+"个店铺！");
					 return false;		 
				 }
				 if(data.demandID>1)
				 {
					  is = 0;
					 alert("一次只能生成一个TA，所选列表包含"+data.demandID+"个TA！如果需要一票发走！请使用合并功能");
					 return false;		 
				 }
				 if(data.keshi>=1)
				 {
					  is = 0;
					 alert("存在未核实的行");
					 return false;		 
				 }
				  if(data.nocang>=1)
				 {
					  is = 0;
					 alert("存在无货可发的行");
					 return false;		 
				 }
				 
				 if(is ==1)
				 {
					  var path = "/oversea/deliveryplan";  
   					 $('#mainform').attr("action", path).submit();;  
				  }
			   },"json");
		 }
	}
	function getshipNums(id,t){

		$.post("/oversea/ajaxbutton", {"op": "getshipNums","id":id,"t":t.value},
			 function(data){
					if(data.code==201)
					{
						alert("发货数不能大于仓库核实可发数！");
						$("#shipNums"+id).val(data.verifyNums);
					    return false;		
					}
			   },"json");
	}
$(function() {
	$("#table2").freezeHeader();
})
</script>
<body class="withvernav">
<div class="bodywrapper">
{{include file='/public/leftmenu.tpl'}}
<div class="centercontent tables">
  <div class="pageheader notab">
    <h1 class="pagetitle">库存需求列表</h1>
    <span class="pagedesc">
    仓库核实可发数每天定时清零，当天未发的货，第二天需要等仓库核实完当天实际可发库存之后才能继续发货。<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;避免仓库核实可发数后无货可发
    </span> 
     <div class="menulist">
        		<ul class="profile_summary">
                        <li> <a href="/oversea/purchasing" class=""><span>申请库存</span></a></li>
                        
                    </ul>
               </div>
    </div>
  <!--pageheader-->
  <div>
  <div style="float:left">  &nbsp;&nbsp; <a href="javascript:void(0)" onClick="savepackingPro()" class="btn btn2 btn_help"><span>生成运输计划 </span></a>
   &nbsp;&nbsp; <a href="javascript:void(0)" onClick="do_merge()" class="btn btn2 btn_help"><span>合并TA </span></a>
   {{if $managers || $classid==10 || $userid==239 || $userid==327 || $userid==294 || $userid==145}}
  <a href="javascript:void(0)" onClick="submitRquestGoods(1)" class="btn btn2 btn_help"><span>仓库确认核实 </span></a>
  {{/if}}
  </div>
  <div class="page">{{$pageList}} 计{{$total}}条记录，共{{$totalpage}}页</div>
 </div>
  <div id="contentwrapper" class="contentwrapper"> 
    <!--搜索栏-->
    <form class="stdform stdform2" method="get" action="/oversea/deliveryplanpro">
      <div class="tableoptions"> 操作时间：
        <input type="text"  name="starttime" value="{{$starttime}} " onClick="WdatePicker({dateFmt:'yyyy-MM-dd '})" class="width100 hasDatepicker" /> - <input type="text"  name="endtime" value="{{$endtime}} " onClick="WdatePicker({dateFmt:'yyyy-MM-dd '})" class="width100 hasDatepicker" />
       其他搜索: <input type="text" name="other" id="other" class="width100" value="{{$other}}" />
        SKU: <input type="text" name="sku" id="sku" class="width100" value="{{$sku}}" />
        {{if $shopname}}
        店铺名：<select name="shopname" id="shopname"  class="selection select2_group">
		<option value="">-请选择-</option>
         {{foreach from=$shopname item=li key=key}}
		  <option value="{{$li.shopname}}" {{if $shopnameselect==$li.shopname}}selected{{/if}}>{{$li.shopname}}</option>
         {{/foreach}}
        
        </select>                      
        {{/if}}
        &nbsp;
         状态：<select name="verify" id="verify"  class="selection">
		<option value="">-请选择-</option>
		  <option value="1" {{if $verify==1}}selected{{/if}}>可发货</option>
         <option value="2" {{if $verify==2}}selected{{/if}}>无货</option>
        </select>                      
        
     
创建者：<input type="text" name="createUser" id="createUser" class="width100" value="{{$createUser}}" /> 
	             
        &nbsp;
        <button class="radius3">Search</button>
         &nbsp; &nbsp; &nbsp; &nbsp;
      </div>
    </form>
    <!--搜索栏结束-->
    <div class="x_content" style="overflow-x:auto;">
    <form class="stdform stdform2" id="mainform" method="post" action="/oversea/ajaxbutton?op=savedeliveryplanpro">
    <input type="hidden" id="submittype" name="submittype" value="0">
    <table cellpadding="0" cellspacing="0" border="0" class="stdtable" id="table2">
      <colgroup>
      <col class="con1" />
      <col class="con0" />
      <col class="con1" />
      <col class="con0" />
      <col class="con1" />
      <col class="con0" />
      <col class="con1" />
      </colgroup>
      <thead>
        <tr>
          <th class="head0"><input name="allchk" id="allchk" type="checkbox" onClick="allSelect('ppid[]')"></th>
          <th class="head0">发货数</th>
           <th class="head0">待发数量</th>
           <th class="head0">已发数量</th>
           <th class="head0">需求数</th>
              <th class="head0">核实可发数</th>
          <th class="head0">商品编号</th>
           <th class="head0">在库</th>
            <th class="head0">调拨待发</th>
            <th class="head0">直发待发</th>
            <th class="head0">海外库存</th>
            <th class="head0">7/30天</th>
             <th class="head0">采购在途</th>
             <th class="head0" width="12%">备注</th>
          <th class="head0" width="8%">商品名称</th>
          <th class="head0">申请编号</th>
          <!--
            <th class="head0">始发仓</th>
            <th class="head0">目的仓</th>
            <th class="head0">运输方式</th>-->
          <th class="head0">店铺</th>
          <th class="head1">申请人</th>
        
         
          
         
         
         <th class="head0">申请时间</th>
          <th class="head0">操作</th>
        </tr>
      </thead>
      <tbody>
      {{foreach from=$list item=li key=key}}
      <tr {{if $li.st==1}}bgcolor="#FFD2D2" title="带商标商品"{{/if}}>
        <td>
         <input name="ppid[]" type="checkbox"  value="{{$li.id}}">
         
        {{if $li.verify_tip==1 && $li.verifyNums==0}}
         无货
        {{else}}
        	{{if $li.verify_tip==0}}
            	无货
            {{else}}
         		<!-- <input name="ppid[]" type="checkbox"  value="{{$li.id}}">-->
       		{{/if}}
        {{/if}}
       <input type="hidden" name="ID[]" id="ID"  value="{{$li.id}}" />
        </td>
        <td>
        {{if $li.verify_tip==0}}
      	 待核实
       	{{else}}
        <input type="text" name="shipNums[{{$li.id}}][]" id="shipNums{{$li.id}}" class="width50" value="{{$li.verifyNums}}" onBlur="getshipNums({{$li.id}},this)" />
        {{/if}}
        </td>
          <td class="center">{{$li.statsbyNum}}</td>
          <td class="center">{{$li.sendnums}}</td>
          <td class="center">{{$li.skunum}}</td>
         <td class="center">
          {{if  $managers ||$classid==10 ||$userid==239 || $userid==327 || $userid==294 || $userid==145}}
          	
          	<input type="text" name="verifyNums[{{$li.id}}][]" id="verifyNums"  {{if $li.verify_tip==0}}style="border: 1px solid red;" {{/if}} class="width50" value="{{if $li.verify_tip==1}}{{$li.verifyNums}}{{else}}{{$li.statsbyNum}}{{/if}}" />
           {{else}}
           		
           		{{if $li.verify_tip==0}}
                	待核实
                {{else}}
                		<input type="hidden" name="verifyNums[{{$li.id}}][]" id="verifyNums" value="{{$li.verifyNums}}" />
           			{{$li.verifyNums}}
                {{/if}}
          {{/if}}
        
        	
        </td>
        
        <td><a href="/product/productlist?filtertype=skuc&other={{$li.goodsno}}" target="_blank">{{$li.goodsno}}</a></td>
         <td class="center" title="1、2号仓在库"><font color="red">{{$li.stock}}</font></td>
          <td class="center" title="调拨待发"><font color="#0000CC">{{$li.Needgoodsstock}}</font></td>
          <td title="直发待发"><font color="#0000CC">{{$li.sendgoodsnum}}</font></td>
          <td class="center" title="海外库存">{{$li.goodsseastock}}</td>
          <td class="center">{{$li.sales1}}/{{$li.sales2}}</td>
            <td class="center">{{$li.in_transit}}
         {{if $li.waitday}}
         	<br>{{$li.waitday}}
         {{/if}}
         </td>
            <td>
        <span style="cursor:pointer" onClick="listTable.edit(this, 'savedeliveryplanpro','{{$li.id}}','{{$li.remark}}')">{{if $li.remark}}{{$li.remark}}{{else}}<font color="#CCCCCC">编辑备注</font>{{/if}}</span>
            </td>
        <td>{{$li.goods_name}}</td>
         <td>{{$li.demand_number}}</td>
         <!--   <td>{{$li.starthouse}}</td>
            <td>{{$li.seawarehouse}}</td>
            <td>{{$li.transportation}}</td>-->
        <td>{{$li.shopname}}</td>
      
        <td>{{$li.create_user}}</td>
       
      
       
       
       
        <td>{{$li.updatetime}}</td>
        <td class="center">
       <a href="/oversea/ajaxbutton?op=demandList&id={{$li.demandID}}" target="_blank">查看</a>
         </td>
      </tr>
      {{/foreach}}      
        </tbody>
        </table>
     </form>
    </div>
    <div class="page">{{$pageList}}</div>
    <br />
    <br />
  </div>
</div>
<!--bodywrapper-->
<!-- 模态框（Modal） -->
 <form action="/oversea/ajaxbutton?op=mergedemand"  method="post" name="qaform" id="qaform"  enctype="multipart/form-data" >
 <input type="hidden" name="demandid_list" id="demandid_list">
  <div class="modal fade" id="returndataModal" tabindex="-1" role="dialog" aria-labelledby="returnModalLabel" aria-hidden="true">
   <div class="modal-dialog">
      <div class="modal-content">
         <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" 
               aria-hidden="true">×
            </button>
            <h4 class="modal-title" id="returnModalLabel">
               所选的SKU，需要移到对应的调拨单
            </h4>
         </div>
         <div class="modal-body">
         
         <table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr >
            <th>调拨单
              </th>
            <td align="left">
            	{{if $Talist}}
                
                <input type="text" name="dw" id="dw" value="" maxlength="200" style="width:100px;line-height:0.4;" class="small_input"> 
                <br><br>
                {{foreach from=$Talist item=li key=key}}
                <button onclick="document.getElementById('dw').value='{{$li.demand_number}}'" type="button">{{$li.demand_number}}</button>
                {{/foreach}}
                <font color="#FF0000">(*必选项)</font>
                
              
              	{{else}}
                	没有二审完成状态的申请调拨单
                {{/if}}
              </td>
          </tr>
        
        </table>
        
         <div class="modal-footer">
            <button type="button" class="btn btn-default" 
               data-dismiss="modal">
               关闭
            </button>
            <button type="button" class="btn btn-primary"  onclick="doqa()">
               提交
            </button>
         </div>
         </div>
      </div><!-- /.modal-content -->
   </div><!-- /.modal-dialog -->
</div><!-- /.modal -->
</form>

</body>
</html>